#pragma once
#include <string>
#include <vector>
#include "OgreVector3.h"
#define EARTHRADIUSMETER 6378.1370f

namespace Ogre {
	class SceneManager;
}
enum LCC;
class Page;
class GdalLoader;
class OgreInitializeSettings;

class MyTerrain {
	public:
		MyTerrain(int edgeLength, const char* path, const char* lulcpath, LCC defaulttype, Ogre::SceneManager* manager, Ogre::ResourceGroupManager*, OgreInitializeSettings* init, const char* tername);
		virtual ~MyTerrain();
		void createLulcPoints();
		static double latToMeter(double latitude);
		static double longToMeter(double longitude, double latitude);
		static double meterToLat(double meter);
		static double meterToLong(double meter, double latitude);
		void createTerrain();

protected:
	Page* createPage(float* data, double xstart, double ystart, double xmax, double ymax, int step, int id);
	Ogre::Vector3 lineToVector(std::string);
	LCC findLCC(Ogre::Vector3 a, Ogre::Vector3 b, Ogre::Vector3 c);
	LCC accessLCC(int x, int y);
	Ogre::Vector3 reduceVector(Ogre::Vector3 in);

	Ogre::SceneManager* manager;
	Ogre::ResourceGroupManager* rmanager;
	int edgeLength;
	std::string path;
	std::string lulcpath;
	std::string name;
	std::vector<Page*> pageVector;
	LCC defaulttype;
	GdalLoader* terrain;
	GdalLoader* lulc;
	unsigned char* lulcdata;
	OgreInitializeSettings* init;
};
